package com.wuliu.web.controller.order;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.wuliu.common.annotation.Log;
import com.wuliu.common.core.controller.BaseController;
import com.wuliu.common.core.domain.AjaxResult;
import com.wuliu.common.enums.BusinessType;
import com.wuliu.system.domain.TspProblem;
import com.wuliu.system.service.ITspProblemService;
import com.wuliu.common.utils.poi.ExcelUtil;
import com.wuliu.common.core.page.TableDataInfo;

/**
 * 问题件Controller
 * 
 * @author realue
 * @date 2023-11-23
 */
@Api(tags = {"问题件控制器"})
@RestController
@RequestMapping("/order/problem")
public class TspProblemController extends BaseController {
    @Resource
    private ITspProblemService tspProblemService;

    /**
     * 查询问题件列表
     */
    @ApiOperation(value = "查询")
    @PreAuthorize("@ss.hasPermi('order:problem:list')")
    @GetMapping("/list")
    public TableDataInfo list(TspProblem tspProblem) {
        tspProblem.setSysAccount(getSysAccount());
        startPage();
        List<TspProblem> list = tspProblemService.selectTspProblemList(tspProblem);
        return getDataTable(list);
    }

    /**
     * 导出问题件列表
     */
    @ApiOperation(value = "导出")
    @PreAuthorize("@ss.hasPermi('order:problem:export')")
    @Log(title = "问题件", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TspProblem tspProblem) {
        tspProblem.setSysAccount(getSysAccount());
        List<TspProblem> list = tspProblemService.selectTspProblemList(tspProblem);
        ExcelUtil<TspProblem> util = new ExcelUtil<TspProblem>(TspProblem.class);
        util.exportExcel(response, list, "问题件数据");
    }

    /**
     * 获取问题件详细信息
     */
    @ApiOperation(value = "详细")
    @PreAuthorize("@ss.hasPermi('order:problem:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return success(tspProblemService.selectTspProblemById(id));
    }

    /**
     * 新增问题件
     */
    @ApiOperation(value = "新增")
    @PreAuthorize("@ss.hasPermi('order:problem:add')")
    @Log(title = "问题件", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TspProblem tspProblem) {
        return toAjax(tspProblemService.insertTspProblem(tspProblem));
    }

    /**
     * 修改问题件
     */
    @ApiOperation(value = "编辑")
    @PreAuthorize("@ss.hasPermi('order:problem:edit')")
    @Log(title = "问题件", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TspProblem tspProblem) {
        return toAjax(tspProblemService.updateTspProblem(tspProblem));
    }

    /**
     * 删除问题件
     */
    @ApiOperation(value = "删除")
    @PreAuthorize("@ss.hasPermi('order:problem:remove')")
    @Log(title = "问题件", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(tspProblemService.deleteTspProblemByIds(ids));
    }
}
